import React, { Component } from 'react'
import BraftEditor, { BuiltInControlType, ExtendControlType } from 'braft-editor'
import { Upload, Icon } from 'antd'

export default function(props) {
  const excludeControls: BuiltInControlType[] = ['media','line-height','letter-spacing','text-color','superscript','subscript','remove-styles','emoji','blockquote','code']
  const extendControls: ExtendControlType[] = [
    {
      key: 'antd-uploader',
      type: 'component',
      component: (
        <Upload
          accept="image/*"
          showUploadList={false}
          customRequest={(options)=>props.editorImgUpload(options)}
        >
          <button type="button" className="control-item button upload-button" data-title="插入图片">
            <Icon type="picture" theme="filled" />
          </button>
        </Upload>
      )
    }
  ]
  return (
    <div className="my-component" style={{ border: "1px solid #e9e9e9" }}>
      <BraftEditor
        value={props.editorState}
        onChange={props.onChange}
        excludeControls={excludeControls}
        extendControls={extendControls}
        /* media={{
          uploadFn: this.editorMediaUpload,
          accepts: {video: false,audio: false,},
          externals: {video: false,audio: false,embed: false,}
        }} */
      />
    </div>
  )
}
